package org.vectrics.recruiter.struts.tag;

import java.text.SimpleDateFormat;

import org.apache.log4j.Logger;
import org.vectrics.common.struts.MenuTag;
import org.vectrics.web.menu.Menu;
import org.vectrics.web.menu.MenuItem;

public class MainMenuTag extends MenuTag {

    private static final long serialVersionUID = -6506366697960627634L;

    static private transient Logger log = Logger.getLogger(MainMenuTag.class);

    static private SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");

    @Override
    public void buildMenu(final Menu menu) {
        MenuItem homeMenu = menu.addItem("home", "Home", "/hrs-public/public/index.do");

        MenuItem credMenu = menu.addItem("company", "Credentials", "/hrs-public/public/credentials/about.do");
        credMenu.addItem("about", "About Us", "/hrs-public/public/credentials/about.do");
        credMenu.addItem("method", "Methodology", "/hrs-public/public/credentials/method.do");
        credMenu.addItem("recent", "Recent Placements", "/hrs-public/public/credentials/triumph.do");
        credMenu.addItem("contact", "Contact Us", "/hrs-public/public/credentials/contactus.do");

        MenuItem candidateMenu = menu.addItem("candidate", "Candidate", "");
        MenuItem profileMenu = candidateMenu.addItem("profile", "My Profile", "/hrs-public/profile/summary.do");
        // profileMenu.addItem("user_profile", "User Profile",
        // "/recruit/profile/summary.do");
        // profileMenu.addItem("skills_wiz", "Skills Wizard",
        // "/recruit/main/user/skill");

        candidateMenu.addItem("job_search", "Job Search", "/hrs-public/public/job/job_search.do");
        MenuItem candArticlesMenu = candidateMenu.addItem("cand_articles", "Articles", "");
        candArticlesMenu.addItem("self_state", "Self Statement",
                "/hrs-public/public/candidate/article/self_statement.do");
        candArticlesMenu.addItem("flash_interview", "Flash Interview",
                "/hrs-public/public/candidate/article/thing_2_know.do");
        candArticlesMenu.addItem("interview_prep", "Interview Preparation",
                "/hrs-public/public/candidate/article/interviewing.do");
        candArticlesMenu.addItem("ans_quest", "Answering Questions",
                "/hrs-public/public/candidate/article/interview_questions.do");
        candArticlesMenu.addItem("ask_quest", "Ask Questions",
                "/hrs-public/public/candidate/article/interview_interviewer.do");
        candArticlesMenu.addItem("resume_temp", "Resume Template",
                "/hrs-public/public/candidate/article/template_resume.do");
        candArticlesMenu.addItem("org_resume", "Organize Resume",
                "/hrs-public/public/candidate/article/organize_resume.do");
        // candArticlesMenu.addItem("skill_asses", "Skills Assessment",
        // "/recruit/article/self_state.do");

        MenuItem employerMenu = menu.addItem("employer", "Employer", "");
        employerMenu.addItem("interviewer_tips", "Working With Recruiter",
                "/hrs-public/public/employer/article/work_with.do");
        employerMenu.addItem("why_recruiter", "Why a Recruiter?", "/hrs-public/public/employer/article/why_search.do");

        MenuItem lifeMenu = menu.addItem("life", "Life Resources", "");
        lifeMenu.addItem("strike_stress", "Strike Out Stress", "/hrs-public/public/life/article/recog_stress.do");
        lifeMenu.addItem("stress_reduction", "Stress Reduction", "/hrs-public/public/life/article/stress_relief.do");
    }

    @Override
    public String getSelected() {
        String formPath = getFormPath();
        String select = "";
        log.info("getSelected() - formPath = " + formPath);

        if (formPath.indexOf("/public/life") >= 0) {
            select = "life";
        } else if (formPath.indexOf("/public/candidate") >= 0) {
            select = "candidate";
        } else if (formPath.indexOf("/profile") >= 0) {
            select = "candidate";
        } else if (formPath.indexOf("/public/employer") >= 0) {
            select = "employer";
        } else if (formPath.indexOf("/public/job") >= 0) {
            select = "candidate";
        } else if (formPath.indexOf("/util") >= 0) {
            select = "";
        } else if (formPath.indexOf("/public/credentials") >= 0) {
            select = "company";
        } else {
            select = "home";
        }
        return select;
    }

    @Override
    protected String getMenuId() {
        return "DEFAULT";
    }

}
